﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel.Description;
using System.ServiceModel;
using System.ServiceModel.Dispatcher;
using System.ServiceModel.Channels;
using System.Collections.ObjectModel;

namespace FlightSearchServer
{
    class CacheBehavior : IEndpointBehavior
    {

        public CacheBehavior( string serverName, string alliance)
        {
            this.serverName = serverName;
            this.alliance = alliance;
        }

        public void AddBindingParameters(ServiceEndpoint endpoint, BindingParameterCollection bindingParameters) { }

        public void ApplyClientBehavior(ServiceEndpoint endpoint, ClientRuntime clientRuntime) 
        {
            foreach (var op in clientRuntime.Operations)
            {
                op.ParameterInspectors.Add( new Caching( serverName, alliance));
            }
        }

        public void ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher) { }

        public void Validate(ServiceEndpoint endpoint) { }

        public string alliance { get; set; }

        public string serverName { get; set; }
    }
}
